package com.power.ding.dao;

import com.plf.core.base.model.Ha_depart;
import com.plf.core.base.model.Ha_user;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.ding.model.Di_dept;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 部门信息 持久层(hibernate)
 */

public interface Di_deptDao extends JpaRepository<Di_dept, Serializable>, JpaSpecificationExecutor<Di_dept>, Repository<Di_dept, Serializable>, Di_deptDaoCustom<Di_dept, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Di_dept s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);

   /**
    * 根据userid查询审批端部门信息
    * @param userid
    * @return
    */
   @Query(value ="select a.* from ha_depart a left join ha_depart_user b on b.departid = a.id where b.userid = :userid", nativeQuery = true)
   List<Map> findHa_departByMobile(String userid);
}
